package com.lfg.leetcode.leetcode200;

import java.util.Arrays;

public class No274hIndex {


    public static void main(String[] args) {
        int ret = hIndex(new int[]{0, 1, 4, 5, 6, 8});
        System.out.println(ret);
    }

    public static int hIndex(int[] citations) {
        if (citations.length == 0) {
            return 0;
        }
        int ret = 0;
        Arrays.sort(citations);
        for (int i = 0; i < citations.length; i++) {
            if (citations[i] >= citations.length - i) {
                ret++;
            }
        }
        return ret;
    }


}
